package com.study.springsecurity.service.security;

import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;


public class MemoryUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws
            UsernameNotFoundException {
        // 1.根据username查询数据库，判断用户名是否存在
       
        // 2.将数据库当中查出来的username和pwd封装到user对象当中返回 第三个参数表示权限
        return new User(username, "$2a$10$guxh7Ajozpck4/kchBICAuO.C8f7zp/ZU06f05PAILenfBNL18uFe", AuthorityUtils.commaSeparatedStringToAuthorityList("admin,"));
    }
}
